# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=hilbish
pkgver=1.2.0
_lunacolors_commit=f2c7686b3d9bbe960c556ca9234768b03fdcc897
_succulent_commit=96dc95c24989be6596ccb9f7f7244d37f03d4acd
pkgrel=1
pkgdesc="Extensible shell configured in Lua"
url="https://github.com/Rosettea/Hilbish"
arch="all"
license="MIT"
depends="lua-inspect"
makedepends="go"
subpackages="$pkgname-doc:_doc"
install="$pkgname.post-install $pkgname.post-upgrade $pkgname.pre-deinstall"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/Rosettea/Hilbish/archive/v$pkgver.tar.gz
	lunacolors-$_lunacolors_commit.lua::https://github.com/Rosettea/Lunacolors/raw/$_lunacolors_commit/init.lua
	succulent-$_succulent_commit.lua::https://github.com/Rosettea/Succulent/raw/$_succulent_commit/init.lua
	"
builddir="$srcdir/Hilbish-$pkgver"

build() {
	go build -v -o hilbish -ldflags "-X main.Version=$pkgver"
}

check() {
	go test ./...
}

package() {
	# Don't add the shell to /etc/shells during the installation
	sed -i '\|/etc/shells|d' Makefile

	DESTDIR="$pkgdir/" make install
	rm -rf "$pkgdir"/usr/share/hilbish/libs/inspect
	install -Dm644 "$srcdir"/"lunacolors-$_lunacolors_commit".lua "$pkgdir"/usr/share/hilbish/libs/lunacolors/init.lua
	install -Dm644 "$srcdir"/"succulent-$_succulent_commit".lua "$pkgdir"/usr/share/hilbish/libs/succulent/init.lua
}

_doc() {
	pkgdesc="$pkgdesc (documentation)"
	mkdir -p "$subpkgdir"/usr/share/hilbish
	mv "$pkgdir"/usr/share/hilbish/docs "$subpkgdir"/usr/share/hilbish/
}

sha512sums="
551385b277aed46ad863dcd07b4759ecbfcccbf6e51cdb8aa07891a182f160af1db265b00f89df460b7c17553b45a4045746a542224331bc988ec2db06f7d5da  hilbish-1.2.0.tar.gz
315e68192cb758c6c8d41d9eca5fa47dcc20d380d644a94b2424449d7a725bec23c0096d082fd48b16554204f25f9f41478a34cc0e04fcd377057699751dbd4f  lunacolors-f2c7686b3d9bbe960c556ca9234768b03fdcc897.lua
5a8b17943c6df88803040d9e5d1cdf04ba69afd590d3e6c345fda607de571d7a373743f50ddb92819fb2a88b3ef6272ea77ac38bf25499c4231406fab103b230  succulent-96dc95c24989be6596ccb9f7f7244d37f03d4acd.lua
"
